package dongtaiguihua;

public class _03青蛙跳石头 {
    //题目见ppt
    //[2,3,1,1,4] true
    //[3,2,1,0,4] false
    public static void main(String[] args) {
        int[] a ={3,2,1,0,4};
        System.out.println(canJump(a));
    }

    private static boolean canJump(int[] a) {
        if (a == null || a.length  == 0){
            return false;
        }
        int n = a.length;
        Boolean[] f = new Boolean[a.length];
        f[0] = true; //初始化
        for (int j = 1; j < a.length;j++){
            f[j] = false;
            for (int i = 0 ; i < j ;i++){
                if (f[i] && a[i] + i >= j){
                    f[j] = true;
                }
            }
        }
        return f[n-1];
    }
}
